<?php
/**
 * LICENSE
 * 
 * [license information]
 * 
 * @category   plugins 
 * @copyright  Copyright (c) 2009 visualidea.org
 * @license    http://license.visualidea.org
 * @version    v 1.0 2009-04-15
 */
require_once 'libs/Smarty/Smarty.class.php';

function quickEditContent($tpl_source, &$smarty)
{
    $patern = '$_@\(\(([0-9]+)\)\)@_$siU';
    
    $matches = array();
    preg_match_all($patern, $tpl_source, $matches);
    
    foreach ($matches[0] as $index=>$search) {
    	if(null != $search && null != $matches[1][$index]) {
    		$url = Nine_Registry::getBaseUrl() . "admin/content/admin/edit-content/gid/{$matches[1][$index]}/lid/" . Nine_Language::getCurrentLangId();
    		$replacement =  "<a style='background: none;padding: 0;margin:0;' target='_blank' href='" . "{$url}'><img src='/layouts/default/helpers/front/img/icon/edit.png' /></a>";
    		$tpl_source = str_replace($search,$replacement,$tpl_source);
    	}
    } 
	
	return $tpl_source;
}
